<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>javascript 钩子</title>
    <script src="https://cdn.bootcss.com/vue/2.4.2/vue.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/velocity/1.2.3/velocity.min.js"></script>
    <style>

    </style>
</head>
<body>
    <div id="app">
        <button @click="show = !show">
            Toggle
        </button>

        <!-- v-bind:css="false" 在时候用js过度效果是，要绑定css属性为false可以跳过vue的对css的检查 -->
        <transition
                v-on:before-enter="beforeEnter"
                v-on:enter="enter"
                v-on:leave="leave"
                v-bind:css="false"
        >
            <p v-if="show">
                Demo
            </p>
        </transition>
    </div>

    <script>
        var vm = new Vue({
            el : '#app',
            data : {
                show : true
            },
            methods: {
                beforeEnter: function (el) {
                    el.style.opacity = 0
                },
                enter: function (el, done) {
                    Velocity(el, { opacity: 1, fontSize: '1.4em' }, { duration: 300 })
                    Velocity(el, { fontSize: '1em' }, { complete: done })
                },
                leave: function (el, done) {
                    Velocity(el, { translateX: '15px', rotateZ: '50deg' }, { duration: 600 })
                    Velocity(el, { rotateZ: '100deg' }, { loop: 2 })
                    Velocity(el, {
                        rotateZ: '45deg',
                        translateY: '30px',
                        translateX: '30px',
                        opacity: 0
                    }, { complete: done })
                }
            }
        });
    </script>
</body>
</html>